
<%@page import="com.guias.consultas.ConsultasBasicas"%>
<%@page import="java.util.Iterator"%>
<%@page import="com.guias.data.Ejecutar"%>
<%@page import="java.util.ArrayList"%>
<%


String gs_opcion = (request.getParameter("opcion")!= null)? request.getParameter("opcion") : "";

if (gs_opcion.equals("1")){
    String id_cosmos = (request.getParameter("id_cosmos")!=null)? request.getParameter("id_cosmos") : "";
    String cedula    = (request.getParameter("cedula")!=null)? request.getParameter("cedula") : "";
    String nombre    = (request.getParameter("nombre")!=null)? request.getParameter("nombre") : "";
    
    String sql_select = "select * from tb_inscritos where 1=1 ";
    sql_select       += (cedula.equals("")==false)? " and cedula='"+cedula+"'" : "";
    sql_select       += (nombre.equals("")==false)? " and upper(nombre) like upper('%"+nombre+"%')" : "";
    sql_select       += (id_cosmos.equals("")==false)? " and id_cosmos='"+id_cosmos+"'" : "";
    
    ArrayList ly_datos = new ArrayList();
    ArrayList ly_campos = new ArrayList();
    Ejecutar exec = new Ejecutar();
    ly_datos = exec.ejecutarSQLselect(sql_select, false);
    if (ly_datos != null){
        %>
            <table id="datos" border="1" >
                <thead> 
                    <tr> 
                        <th>Cedula</th> 
                        <th>Nombre</th> 
                        <th>Telefono</th> 
                        <th>Celular</th> 
                    </tr> 
                </thead> 
                <tbody>
         <% 
         for (Iterator it = ly_datos.iterator(); it.hasNext();){
             ly_campos = (ArrayList) it.next();
             if (ly_campos != null){
                 String id = (String) ly_campos.get(1);
                 String cedula_lis = (String) ly_campos.get(2);
                 String nombre_lis = (String) ly_campos.get(4);
                 String telefono = (String) ly_campos.get(5);
                 String celular = (String) ly_campos.get(6);
                 
                 %>
                 
                 
                     <tr onclick="javascrip:cargarDetalle('<%=id%>')">
                         <td><%=cedula_lis%></td>
                         <td><%=nombre_lis%></td>
                         <td><%=telefono%></td>
                         <td><%=celular%></td>
                     </tr>
                 
                 
                 <% 
             }
         }
            
    }
    %>
                </tbody>
            </table>
    
    <% 
    
}

if (gs_opcion.equals("2")){
    String id = (request.getParameter("id")!=null)? request.getParameter("id") : "";
    if (!id.equals("")){
        
        String sql_select = "select * from tb_inscritos where id_cosmos='"+id+"'";
        ArrayList ly_datos = new ArrayList();
        ArrayList ly_campos = new ArrayList();
        Ejecutar exec = new Ejecutar();
        ly_datos = exec.ejecutarSQLselect(sql_select, false);
        if (ly_datos != null){
        %>
    
                <table border="1">
                    <thead>
                        <tr>
                            <th>Nombre</th>
                            <th>Telefono</th>
                            <th>Celular</th>
                            <th>Direccion</th>
                            <th>Fecha Nacimiento</th>
                            <th>Departamento</th>
                            <th>Municipio</th>
                        </tr>
                    </thead>
                    <tbody>
    
    <% 
            com.guias.consultas.ConsultasBasicas cb = new ConsultasBasicas();
            for (Iterator it=ly_datos.iterator(); it.hasNext();){
                ly_campos = (ArrayList) it.next();
                if (ly_campos != null){
                    String id_ins = (String) ly_campos.get(1);
                    String cedula = (String)ly_campos.get(2);
                    String email = (String) ly_campos.get(3);
                    String nombre = (String) ly_campos.get(4);
                    String telefono = (String) ly_campos.get(5);
                    String celular = (String) ly_campos.get(6);
                    String direccion = (String) ly_campos.get(7);
                    String fecha_nacimiento = (String) ly_campos.get(8);
                    String departamento = cb.getNombreDepartamento((String) ly_campos.get(9) );
                    String ciudad = cb.getNombreMunicipio( (String) ly_campos.get(9), (String) ly_campos.get(10));
                    
                    %>
                    
                    
                        <tr onclick="javascript:verNotas('<%=id_ins%>')" >
                            <td><%=nombre%></td>
                            <td><%=telefono%></td>
                            <td><%=celular%></td>
                            <td><%=direccion%></td>
                            <td><%=fecha_nacimiento%></td>
                            <td><%=departamento%></td>
                            <td><%=ciudad%></td>
                        </tr>
                    
                    
                    <%
                }
            }
       }
        %>
                </tbody>
            </table>
        <% 
    }
}

if (gs_opcion.equals("3")){
    // cargar cursos
    String id = (request.getParameter("id")!=null)? request.getParameter("id") : "";
    if (!id.equals("")){
        com.guias.consultas.ConsultasBasicas cb = new ConsultasBasicas();
        String sql_select = "select * from tb_historial_inscrito where id_cosmos = '"+id+"'";
        ArrayList ly_datos = new ArrayList();
        ArrayList ly_campos = new ArrayList();
        Ejecutar exec = new Ejecutar();
        ly_datos = exec.ejecutarSQLselect(sql_select, false);
        if (ly_datos != null){
        %>
            <table id="datos" border="1" >
                <thead> 
                    <tr> 
                        <th>Guia</th> 
                        <th>Nota</th> 
                        <th>Sustentacion</th> 
                        <th>Credito</th>
                    </tr> 
                </thead> 
                <tbody>
         <% 
         for (Iterator it = ly_datos.iterator(); it.hasNext();){
             ly_campos = (ArrayList) it.next();
             if (ly_campos != null){
                 String id_his = (String) ly_campos.get(0);
                 String guia = cb.getNombreGuia((String) ly_campos.get(2));
                 String nota = (String) ly_campos.get(3);
                 String sustentacion = (String) ly_campos.get(4);
                 String credito = (String) ly_campos.get(5);
                 %> 
                 
                 
                     <tr>
                         <td><%=guia%></td>
                         <td><%=nota%></td>
                         <td><%=sustentacion%></td>
                         <td><%=credito%></td>
                     </tr>
                 
                 
                 <% 
             }
         }
         %>
                    </tbody>
                </table>

        <%    
        }
        
    }
}

%>